package com.gitee.feizns.quickstart.spring;

import com.gitee.feizns.dynamic.function.ThrowableRunnable;
import lombok.SneakyThrows;
import org.springframework.util.StopWatch;

/**
 * 秒表
 * @author feizns
 * @since 2025/4/11
 */
public class StopWatches {

    /**
     * 跑
     * @param runnable 可运行
     * @return {@link StopWatch }
     */
    @SneakyThrows
    public static StopWatch run(ThrowableRunnable runnable) {
        StopWatch watch = new StopWatch();
        watch.start();
        runnable.run();
        watch.stop();
        return watch;
    }

}
